package com.liqi.monitor.service.impl;

import java.util.List;

import com.liqi.common.annotation.DataScope;
import com.liqi.common.annotation.DataSource;
import com.liqi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.liqi.monitor.mapper.DvDeploymentSystemMapper;
import com.liqi.monitor.domain.DvDeploymentSystem;
import com.liqi.monitor.service.IDvDeploymentSystemService;

/**
 * 设备运行状态Service业务层处理
 * 
 * @author zh
 * @date 2022-10-25
 */

@Service
public class DvDeploymentSystemServiceImpl implements IDvDeploymentSystemService 
{	
    @Autowired
    private DvDeploymentSystemMapper dvDeploymentSystemMapper;

    /**
     * 查询设备运行状态
     * 
     * @param id 设备运行状态主键
     * @return 设备运行状态
     */
    @DataScope(deptAlias = "d" , userAlias = "u")
    @Override
    public DvDeploymentSystem selectDvDeploymentSystemById(Long id)
    {
        return dvDeploymentSystemMapper.selectDvDeploymentSystemById(id);
    }

    /**
     * 查询设备运行状态列表
     * 
     * @param dvDeploymentSystem 设备运行状态
     * @return 设备运行状态
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u", regionAlias = "r", groupAlias = "g")
    public List<DvDeploymentSystem> selectDvDeploymentSystemList(DvDeploymentSystem dvDeploymentSystem)
    {
        return dvDeploymentSystemMapper.selectDvDeploymentSystemList(dvDeploymentSystem);
    }

    /**
     * 新增设备运行状态
     * 
     * @param dvDeploymentSystem 设备运行状态
     * @return 结果
     */
    @Override
    public int insertDvDeploymentSystem(DvDeploymentSystem dvDeploymentSystem)
    {
        return dvDeploymentSystemMapper.insertDvDeploymentSystem(dvDeploymentSystem);
    }

    /**
     * 修改设备运行状态
     * 
     * @param dvDeploymentSystem 设备运行状态
     * @return 结果
     */
    @Override
    public int updateDvDeploymentSystem(DvDeploymentSystem dvDeploymentSystem)
    {
        dvDeploymentSystem.setUpdateTime(DateUtils.getNowDate());
        return dvDeploymentSystemMapper.updateDvDeploymentSystem(dvDeploymentSystem);
    }

    @Override
	public int updateDeploymentSystemByDeviceId(DvDeploymentSystem dvDeploymentSystem) {
    	dvDeploymentSystem.setUpdateTime(DateUtils.getNowDate());
        return dvDeploymentSystemMapper.updateDeploymentSystemByDeviceId(dvDeploymentSystem);
	}

	/**
     * 批量删除设备运行状态
     * 
     * @param ids 需要删除的设备运行状态主键
     * @return 结果
     */
    @Override
    public int deleteDvDeploymentSystemByIds(Long[] ids)
    {
        return dvDeploymentSystemMapper.deleteDvDeploymentSystemByIds(ids);
    }

    /**
     * 删除设备运行状态信息
     * 
     * @param id 设备运行状态主键
     * @return 结果
     */
    @Override
    public int deleteDvDeploymentSystemById(Long id)
    {
        return dvDeploymentSystemMapper.deleteDvDeploymentSystemById(id);
    }

	@Override
	public DvDeploymentSystem selectDeploymentByDeviceId(String deviceId) {
		return dvDeploymentSystemMapper.selectDeploymentByDeviceId(deviceId);
	}

    @Override
    public DvDeploymentSystem selectByDeviceId(String deviceId) {
        return dvDeploymentSystemMapper.selectByDeviceId(deviceId);
    }

    /**
     * 根据自编设备号修改状态日志信息
     * @param dvLog
     * @return
     */
    @Override
    public int updateStatusLogInCode(DvDeploymentSystem dvDeploymentSystem) {
    	dvDeploymentSystem.setUpdateTime(DateUtils.getNowDate());
        return dvDeploymentSystemMapper.updateStatusLogInCode(dvDeploymentSystem);
    }
    
    @Override
    public List<DvDeploymentSystem> selectDvEquipmentSystemForTask() {
        return dvDeploymentSystemMapper.selectDvEquipmentSystemForTask();
    }
    
    @Override
    public List<DvDeploymentSystem> selectDvEquipmentSystemListForTask(DvDeploymentSystem dvDeploymentSystem) {
        return dvDeploymentSystemMapper.selectDvEquipmentSystemListForTask(dvDeploymentSystem);
    }

}
